<script setup lang="ts">
import { ref } from "vue";
import { agentOptionsType, FormProps } from "@/utils/commonType";
import { formRules } from "./utils/rule";

const props = withDefaults(defineProps<FormProps<agentOptionsType>>(), {
  formInline: () => ({
    pid: "",
    section: "",
    optionItem: "",
    optionDesc: "",
    sectionName:""
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="配置块" prop="section">
      <el-select
        v-model="newFormInline.section"
        placeholder="请选择代理配置块"
      >
        <el-option label="全局块" value="global" />
        <el-option label="事件块" value="events" />
        <el-option label="HTTP块" value="http" />
        <el-option label="服务云块" value="server" />
        <el-option label="应用块" value="location" />
      </el-select>
    </el-form-item>
    <el-form-item label="配置项" prop="optionItem">
      <el-input
        v-model="newFormInline.optionItem"
        clearable
        placeholder="请输入代理配置项"
      />
    </el-form-item>
    <el-form-item label="配置项说明" prop="optionDesc">
      <el-input
        v-model="newFormInline.optionDesc"
        placeholder="请输入配置项说明"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
